package test_system.menu;

import test_system.controller.TestController;
import test_system.menu.language.EnLanguage;
import test_system.menu.language.Language;
import test_system.menu.language.RuLanguage;
import test_system.menu.language.UaLanguage;
import test_system.parser.ParserCSV;
import test_system.questions.Answer;
import test_system.questions.QuestionWrapper;
import test_system.user_logic.Admin;
import test_system.user_logic.Session;
import test_system.user_logic.SessionSaver;
import test_system.user_logic.UserAnswers;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;


public class MenuTeacher extends Menu {

    private Scanner in = new Scanner(System.in);


    public ArrayList<Answer> getUserAnswers(ArrayList<Answer> answers, int index) {
        QuestionWrapper question;
        for (int i = index; i < TestController.test.getTestLength(); ) {


            question = outputQuestion(i);
            System.out.println("This is " + question.getQuestionsLevel());
            String ans = in.nextLine();
            if (ans.equals("s")) {
                SessionSaver ss = new SessionSaver(TestController.userSession.getUser(), TestController.test, answers);
                ss.save();
            } else if (ans.equals("undo")) {
                i--;
                continue;
            } else if (ans.equals("redo")) {
                i++;
                continue;
            }
            Answer answer = conventUserAnswer(ans, question);
            answers.add(answer);
            System.out.println("You answer " + answer.isRight());
            i++;
        }

        return answers;
    }
}
